package com.dwork.base.exception;

public class DworkException extends Exception {

	private static final long serialVersionUID = -5062390266059090468L;
	
	private String code;
	private String message;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public DworkException(DworkExceptionCode code) {
		super(String.format("%s：%s", code.getCode(), code.getMessage()));
		this.code = code.getCode();
		this.message = code.getMessage();
	}

	public DworkException(DworkExceptionCode code, String message) {
		super(String.format("%s：%s-->%s", code.getCode(), code.getMessage(),
				message));
		this.code = code.getCode();
		this.message = code.getMessage() + "-->" + message;
	}

	public DworkException(DworkExceptionCode code, String message,
			Throwable cause) {
		super(String.format("%s：%s-->%s", code.getCode(), code.getMessage(),
				message), cause);
		this.code = code.getCode();
		this.message = code.getMessage() + "-->" + message;
	}

	public DworkException(DworkExceptionCode code, Throwable cause) {
		super(String.format("%s：%s", code.getCode(), code.getMessage()), cause);
		this.code = code.getCode();
		this.message = code.getMessage();
	}
}
